﻿using com.fmtx.IDal;
using fmtx.Framework.DALFactory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace website.Areas.Website.Controllers
{
    public class CountryController : Controller
    {
        //
        // GET: /Website/Country/
        ICountry _country = DataAccess<ICountry>.GetObject();
        IArea _area = DataAccess<IArea>.GetObject();
        ICity _city = DataAccess<ICity>.GetObject();

        public ActionResult Index(int id,int p=1)
        {
            int index= Math.Max(p-1, 0);
            var model = _country.Get(id);
            ViewBag.area = _area.GetAll();
            int count=0;
            ViewBag.citys = _city.QueryByCountry(id, index, 12, ref count);
            ViewBag._PageBean = new PageBean(p, 12, count, this);
            ViewBag.clist = _country.QueryByArea(model.AreaId);
            return View(model);
        }

    }
}
